install PDO_MYSQL - mysql_config and header files problem

chris (2007-06-06 23:46:32)
19538 views
4 replies
Installing the PDO_MySQL mysql driver for PDO can be problematic if either you don't have mysql_config installed, or the configure script doesn't instantly find mysql_config on your filesystem.

I recently installed mysql 5.1, then recompiled php 5.2.3 with mysql and pdo support enabled. The next step was just to install the mysql driver for PDO. The first problem was that I could not get the driver to download and install straight off the PDO repository (as you can with pear modules). The next issue looked like this:

chris@snackerjack-lx:/usr/src$ sudo pecl install PDO_MYSQL
7 source files, building
running: phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
building in /var/tmp/pear-build-root/PDO_MYSQL-1.0.2
running: /tmp/pear/cache/PDO_MYSQL-1.0.2/configure
checking for egrep... grep -E
checking for a sed that does not truncate output... /bin/sed
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
.
.etc..
.
checking for MySQL support for PDO... yes, shared
checking for mysql_config... not found
configure: error: Cannot find MySQL header files under
ERROR: `/tmp/pear/cache/PDO_MYSQL-1.0.2/configure' failed


If you trace the fatal error, it's due to the PDO configure script being unable to find the MySQL header. Go up one step further and the configure reports that it can't find mysql_config. Thchris@snackerjack-lx:/usr/src$ locate mysql_config
/usr/local/mysql/bin/mysql_config
/usr/local/mysql/man/man1/mysql_config.1
e lines below show that mysql_config is actually installed. To make matters even clearer, php was compiled with the option '--with-mysql=/usr/local/mysql/', but it seems the pecl installer doesn't think about that.

chris@snackerjack-lx:/usr/src$ locate mysql_config
/usr/local/mysql/bin/mysql_config
/usr/local/mysql/man/man1/mysql_config.1

The way I was able to fix this issue was simply by providing a symbolic link from the binary to /usr/bin/mysql_config

chris@snackerjack-lx:/usr/src$ sudo ln -s /usr/local/mysql//bin/mysql_config /usr/bin/mysql_config

The extension then compiles without problem!

hth

christo

comment
chris
2007-06-25 08:21:52

quick PHP with PDO install

Just as an upadte to this, there is a simpler way to install PHP with PDO - it seems you can request it as an option at compile time. Run your configure like this:

./configure --with-apxs2=/usr/local/apache/bin/apxs --with-zlib-dir=../zlib-1.2.3/ --with-pdo-mysql=/usr/local/mysql --with-mysql=/usr/local/mysql

That was last tested with PHP 5.2.3.

reply icon
jaafonseca
2007-11-20 18:35:14

hey Chris

you can also solve this by installing libmysqlclient15-dev:

sudo apt-get install libmysqlclient15-dev

reply icon
chris
2007-11-24 11:48:19

I was building php on Slackware, so didn't have the debian/ubuntu package tools to hand.. However just adding the pdo directives to the ./configure works just fine.

cheers
christo


reply icon
Leonardo
2009-05-22 15:44:22

thanks!

Thank you very much, I had the exactly same problem compiling php, the symbolic link solved it!
reply iconedit reply